from django.shortcuts import render

# Create your views here.
from rest_framework.response import Response
from rest_framework.views import APIView
from .ser import *
class ShowCourse(APIView):
    def get(self,request):
        cla = Sclass.objects.all()
        ser = SclassSer(cla,many=True)
        return Response(ser.data)

class Reg(APIView):
    def post(self,request):
        ser = StuSer(data=request.data)
        if ser.is_valid():
            ser.save()
            stu = Stu.objects.filter(username = request.data.get('username')).first()
            return Response({'cods':200,'id':stu.id,"name":stu.name})
        else:
            print(ser.errors)
            return Response({'cods':2000000})
    def get(self,request):
        id = request.GET.get('id')
        stu = Stu.objects.filter(id=id).first()
        ser = ShowCourse(stu)
        return Response({'cods':200,'cla':ser.data})
        # return Response('ok')
class ChangeClass(APIView):
    def et(self,request):


